/*
 * 该controller放置所有不需要走登录校验的接口
 *
 */

module.exports = {
  /**
   * 登录
   * @param req
   * @param res
   */
  doLogin(req,res){
    let param={
      phone:req.param('phone'),
      verificationCode:req.param('verificationCode'),
      openid:req.session.wechat.openid,
      headimgurl:req.session.wechat.headimgurl
    };
    ServerApiService.doLogin(req, param)
      .then(result => {
        if(200 == result.code){
          SessionUtil.setUserIntoSession(req,result.data);
        }
        result.enterUrl = req.session.enterUrl;
        SessionUtil.setSessionValue(req,"enterUrl","");
        res.send(result)
      })
      .catch(err => {
        sails.log.error(err)
      })
  },
}
